package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Sebas
 */
@Entity
@Table(name = "director")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Director.findByName", query = "SELECT d FROM Director d WHERE d.dirName = :dirName OR d.dirLastname = :dirLastname"),
    @NamedQuery(name = "Director.findAll", query = "SELECT d FROM Director d"),
    @NamedQuery(name = "Director.findByIdDirector", query = "SELECT d FROM Director d WHERE d.idDirector = :idDirector"),
    @NamedQuery(name = "Director.findByDirBirthdate", query = "SELECT d FROM Director d WHERE d.dirBirthdate = :dirBirthdate")})
public class Director implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_director")
    private Integer idDirector;
    @Basic(optional = false)
    @Lob
    @Column(name = "dir_name")
    private String dirName;
    @Basic(optional = false)
    @Lob
    @Column(name = "dir_lastname")
    private String dirLastname;
    @Basic(optional = false)
    @Lob
    @Column(name = "dir_picture")
    private String dirPicture;
    @Basic(optional = false)
    @Column(name = "dir_birthdate")
    @Temporal(TemporalType.DATE)
    private Date dirBirthdate;
    @Basic(optional = false)
    @Lob
    @Column(name = "dir_birthplace")
    private String dirBirthplace;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "directorIdDirector")
    private Collection<Movie> movieCollection;

    public Director() {
    }

    public Director(Integer idDirector) {
        this.idDirector = idDirector;
    }

    public Director(Integer idDirector, String dirName, String dirLastname, String dirPicture, Date dirBirthdate, String dirBirthplace) {
        this.idDirector = idDirector;
        this.dirName = dirName;
        this.dirLastname = dirLastname;
        this.dirPicture = dirPicture;
        this.dirBirthdate = dirBirthdate;
        this.dirBirthplace = dirBirthplace;
    }

    public Integer getIdDirector() {
        return idDirector;
    }

    public void setIdDirector(Integer idDirector) {
        this.idDirector = idDirector;
    }

    public String getDirName() {
        return dirName;
    }

    public void setDirName(String dirName) {
        this.dirName = dirName;
    }

    public String getDirLastname() {
        return dirLastname;
    }

    public void setDirLastname(String dirLastname) {
        this.dirLastname = dirLastname;
    }

    public String getDirPicture() {
        return dirPicture;
    }

    public void setDirPicture(String dirPicture) {
        this.dirPicture = dirPicture;
    }

    public Date getDirBirthdate() {
        return dirBirthdate;
    }

    public void setDirBirthdate(Date dirBirthdate) {
        this.dirBirthdate = dirBirthdate;
    }

    public String getDirBirthplace() {
        return dirBirthplace;
    }

    public void setDirBirthplace(String dirBirthplace) {
        this.dirBirthplace = dirBirthplace;
    }

    @XmlTransient
    public Collection<Movie> getMovieCollection() {
        return movieCollection;
    }

    public void setMovieCollection(Collection<Movie> movieCollection) {
        this.movieCollection = movieCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDirector != null ? idDirector.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Director)) {
            return false;
        }
        Director other = (Director) object;
        if ((this.idDirector == null && other.idDirector != null) || (this.idDirector != null && !this.idDirector.equals(other.idDirector))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Director[ idDirector=" + idDirector + " ]";
    }
    
}
